package exceptions;

class MyException extends Exception{
	public MyException(String x){
		super( x );
	}
}
public class MyExcept {
	private static final int MAX_VALUE_FOR_RESULT = 2000;
	
	private static int compute(int[] a) throws MyException {
		int result = 0;
		for (int x : a)
			result = result + 10000 / (50 - x);
		if (result > MAX_VALUE_FOR_RESULT)
			throw new MyException("at line 16 of compute method");
		return result;
	}
	public static void main(String[] arg) {
		int[] a = new int[10];
		for (int i = 0; i < a.length; i++)
			a[i] = i;
		for (int i = 0; i < a.length; i++)
			System.out.println("a [" + i + "] is " + a[i]);
		int result = 0;
		try {
			result = compute(a);
		} catch (ArithmeticException ae) {
			
		} catch (MyException me){
			me.printStackTrace();
			System.err.println(" Looks like the result will exceed " + MAX_VALUE_FOR_RESULT );
		}
		System.out.println("The result of array computation is " + result);
		System.out.println("Done!");
	}
}